package cmd

import (
	"pkgtool/internal/installer"

	"github.com/spf13/cobra"
)

var configPath string

var installCmd = &cobra.Command{
	Use:   "install",
	Short: "安装软件包",
	Long:  `根据配置文件安装指定的软件包`,
	RunE: func(cmd *cobra.Command, args []string) error {
		inst, err := installer.NewInstaller(configPath)
		if err != nil {
			return err
		}
		return inst.Install()
	},
}

func init() {
	installCmd.Flags().StringVarP(&configPath, "config", "c", "install.json", "配置文件路径")

	rootCmd.AddCommand(installCmd)
}
